﻿using MediatR;
using Traceability.App.Applications.Command.IMage;
using Traceability.Domain.Entity;
using Traceability.Domain.Repository;
using Traceability.Enum;

namespace Traceability.App.Applications.CommandHand.IMage
{
    public class UpdatebatchCommandHand : IRequestHandler<UpdatebatchCommand, ApiResult<ImageModel>>
    {
        private readonly IBaseRepository<ImageModel> _image;

        public UpdatebatchCommandHand(IBaseRepository<ImageModel> image)
        {
            _image = image;
        }

        public Task<ApiResult<ImageModel>> Handle(UpdatebatchCommand request, CancellationToken cancellationToken)
        {
            var  result=new ApiResult<ImageModel>();
            var imgs = _image.GetAll().FirstOrDefault(x => x.Batch == request.Batch && x.Type == request.Type);
            
            result.Message = "修改成功";
            if (imgs != null)
            {
                result.data = imgs;
            }
           
           

            return Task.FromResult(result);

            
            
        }
    }
}
